{% extends "base.volt" %}

{% block pageHeader %}
    {{ stylesheet_link("/libs/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css", false) }}
{% endblock %}

{% block pageFooter %}
    {{ javascript_include("/libs/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js", false) }}
    {{ javascript_include("/libs/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.zh-CN.min.js", false) }}
    {{ javascript_include("/assets/manage/js/order/list.js", false) }}
{% endblock %}

{% block content %}
    <div class="col-xs-12" id="order_list">
        <ol class="breadcrumb">
            <li><a href="{{ url.get('order/list') }}">订单管理</a></li>
            <li class="active">订单列表</li>
        </ol>

        <div class="panel panel-default">
            <div class="panel-body">
                <form class="form-inline" role="form" action="" method="get">
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterId">订单号:</label>
                            <input class="form-control input160" type="text" name="filterId" id="filterId" value="{{ filterId > 0 ? filterId : '' }}" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterUserId">用户ID:</label>
                            <input class="form-control input160" type="text" name="filterUserId" id="filterUserId" value="{{ filterUserId > 0 ? filterUserId : '' }}" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterState">订单状态:</label>
                            <select class="form-control" name="filterState" id="filterState">
                                <option value="-10000" {{ filterState == -10000 ? 'selected="selected"' : '' }} >全部</option>
                                {% for k, v in OrderStateList() %}
                                <option value="{{ k }}" {{ filterState == k ? 'selected="selected"' : '' }} >{{ v }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterDt">下单时间:</label>
                            <div class="input-daterange input-group" id="filterDt">
                                <input type="text" class="form-control input-small" name="filterDtStart" id="filterDtStart" value="{{ filterDtStart }}"/>
                                <span class="input-group-addon"> 至 </span>
                                <input type="text" class="form-control input-small" name="filterDtEnd" id="filterDtEnd" value="{{ filterDtEnd }}"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary"><i class="fa fa-filter"></i> 搜 索</button>
                    </div>
                </form>
            </div>
        </div>

        <table class="table table-hover">
            <thead>
            <tr>
                <th style="width: 160px;">ID</th>
                <th style="width: 60px;">用户ID</th>
                <th style="width: 200px;">用户名</th>
                <th style="width: 120px;">联系电话</th>
                <th style="width: 60px;">金额</th>
                <th>购买服务</th>
                <th style="width: 100px;">支付方式</th>
                <th style="width: 60px;">状态</th>
                <th style="width: 180px;">下单时间</th>
                <th style="width: 200px;"></th>
            </tr>
            </thead>
            {% for d in data %}
                <tr>
                    <td>{{ d.order_long_id }}</td>
                    <td>{{ d.user_id|e }}</td>
                    <td>{{ d.user_nickname|e }}</td>
                    <td>{{ d.order_mobile|e }}</td>
                    <td>{{ d.order_money }}</td>
                    <td> </td>
                    <td>{{ d.order_pay_state > 0 ? PayTypeValueToStr(d.order_pay_type) : '' }}</td>
                    <td>{{ OrderStateValueToStr(d.order_state) }}</td>
                    <td>{{ d.order_addtime }}</td>
                    <td>
                        <div class="dropdown {{ in_array(d.order_state, [-10, -2,-1 ,0]) ? 'hide' : ''}}">
                            <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu{{ d.order_id }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><i class="fa fa-cogs"></i> 操作 <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu{{ d.order_id }}">
                                {% if d.order_state != -10 %}
                                    <li><a href="javascript:void(0)" durl="{{ url.get('order/setRefund') }}" did="{{ d.order_id }}" dstate="1" class="but_set_refund"><i class="fa fa-money fa-fw"></i> 设置退款成功</a></li>
                                {% endif %}
                            </ul>
                        </div>
                    </td>
                </tr>
            {% endfor %}
        </table>

        {{ this.tagNav.page(
        page,
        total,
        limit,
        url.get('order/list', [
            'filterId': filterId,
            'filterUserId': filterUserId,
            'filterState': filterState,
            'filterDtStart': filterDtStart,
            'filterDtEnd': filterDtEnd,
            'page': '__PAGE__'
        ]
        )) }}
    </div>
{% endblock %}